import request from "@/utils/request";
import { io } from "socket.io-client";
export async function getMsgList() {
    try {
        const res = await request.get('/message/get-all')
        return res.data
    } catch (error) {
        console.log(error)
    }
}

export function connectSocket(userId,groupIds) {
    const socket = io(`https://${location.host}?userId=${userId}`
        , {
        ackTimeout: 10000,
        retries: 5,
        autoConnect: true,
        transports: ['websocket'],
        withCredentials: true,
    });
    socket.emit("joinAll", userId,groupIds)
    return socket;
}
export function disconnectSocket(socket) {
    if (socket) {
        socket.disconnect();
    }
}